
from typing import List
from FieldInfo import FieldInfo

class TableInfo:
    """表信息类"""
    def __init__(self, name: str, fields: List[FieldInfo]):
        self.name = name
        self.fields = fields

    def get_class_name(self) -> str:
        """获取类名（驼峰命名）"""
        # 去除表前缀
        name = self.name
        from Config import GENERATE_CONFIG
        if GENERATE_CONFIG['table_prefix'] and name.startswith(GENERATE_CONFIG['table_prefix']):
            name = name[len(GENERATE_CONFIG['table_prefix']):]

        # 转换为驼峰命名
        components = name.split('_')
        return ''.join(x.capitalize() for x in components)

    def get_mapper_class_name(self) -> str:
        """获取Mapper类名"""
        class_name = self.get_class_name()
        return class_name + 'Mapper'  # 返回如 RepairContentMapper
